<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<!-- import CSS -->
		<script src="../../js/commonCss.js"></script>
		<title>在线考试类别管理</title>
	</head>
	<body>
		<div id="app" v-cloak>
			<div class="pd10 border-bottom ft-14 h40">
				在线考试类别管理
				<el-button class="f-r" type="primary" icon="el-icon-plus" @click="addCont">添加考试类别</el-button>
			</div>
			<div class="pd10">		
				<el-form :inline="true" :model="formInline" class="demo-form-inline">					
					<el-form-item>
						<el-input v-model="formInline.name" type="text" placeholder="请输入名称"></el-input>
					</el-form-item>
					<el-form-item>
						<el-button type="primary" @click="search">查询</el-button>
					</el-form-item>
				</el-form>
				<el-table :data="tableData" stripe border style="width: 100%">
					<el-table-column prop="name" label="类别名称"></el-table-column>
					<el-table-column label="操作">
						<template slot-scope="scope">
							<el-button @click="handleEdit(scope.row)" type="text" size="medium">编辑</el-button>
							<el-button @click="handleDelete(scope.row)" type="text" size="medium" class="color-F56C6C">删除</el-button>
						</template>
					</el-table-column>
				</el-table>				
				<!-- 分页 -->
				<div class="bottomstate">
					<el-pagination class="f-r mt5" background @current-change="handleCurrentChange" :current-page="page" :page-size="limit" layout="total,prev, pager, next,jumper"
					 :total="total" ></el-pagination>
				</div>
			</div>
			<!-- 修改 -->
			<el-dialog :title="title" :visible.sync="dialogFormVisible">
				<el-form :model="form" label-width="120px">
					<el-form-item label="类别名称" >
						<el-input v-model="form.name" autocomplete="off" style="width:300px;"></el-input>
					</el-form-item>
				</el-form>
				<div class="dialog-footer text-r">
					<el-button @click="dialogFormVisible = false">取 消</el-button>
					<el-button type="primary" @click="onSubmit">确 定</el-button>
				</div>
			</el-dialog>
		</div>
	</body>
	<script src="/jeefast/elementui-lib/lib/vue.js"></script>
	<script src="/jeefast/elementui-lib/lib/index.js"></script>
	<script src="/jeefast/js/jquery-1.9.1.min.js"></script>
	<script src="/jeefast/js/axios.js"></script>
	<script src="/jeefast/js/data.js"></script>
	<script>
		var app = new Vue({
			el: "#app",
			mixins: [mix],
			data: function() {
				return {
					formInline:{
						name:""
					},
					tableData: [{
						name:"专业素养",
					},{
						name:"金融保险"
					},{
						name:"政策法规"
					}],					
					// 修改
					title:"",
					dialogFormVisible: false,
					form: {
						name: ""
					},
				}
			},
			methods: {
				search:function(){
					console.log(this.formInline)
				},
				addCont:function(){
					this.title="添加类别"
					this.dialogFormVisible=true
				},
				handleEdit:function(row){
					console.log(row)
					this.title = "编辑类别"
					this.dialogFormVisible = true
					this.form = row
				},
				// 删除
				handleDelete:function(row){
					let that = this
					that.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
						confirmButtonText: '确定',
						cancelButtonText: '取消',
						type: 'warning'
					}).then(() => {
						that.$message({
							type: 'success',
							message: '删除成功!'
						});
					}).catch(() => {
						that.$message({
							type: 'info',
							message: '已取消删除'
						});          
					});
				},
				// 确定
				IsNull: function() {
					let flag = false;
					if (this.form.name == "") {
						this.$message.error('名称不能为空');
						return flag = true;
					}
				},
				onSubmit:function(){
					let that = this;
					if (that.IsNull()) {
						return;
					}
					console.log('===',this.form)
					
					this.dialogFormVisible = false
				},
			},
			created() {
				
			},
		});
	</script>
</html>
